#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
const int SIZE = 1e6+5;
struct node{
    int d,v,a;
}e[N];
int t,n,m,l0,v0,p[N],ans1,ans2;
bool vis[N];
bool l[N];
int check(){
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++){
        int d=e[i].d,v=e[i].v,a=e[i].a;
        if(a <= 0 && v<=v0)continue;
        for(int j=1;j<=m;j++){
            if(!l[j]){
                if(d<=p[j] && v*v+2*a*(p[j]-d)>v0*v0){
                    vis[i]=1;
                    break;
                }
            }
        }
    }
    return accumulate(vis+1,vis+n+1,0);
}
void dfs(int dep){
    if(dep>n){
        if(check() == ans1)
            ans2=max(ans2,accumulate(l+1,l+n+1,0));
        return ;
    }
    l[dep]=0;dfs(dep+1);
    l[dep]=1;dfs(dep+1);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>l0>>v0;
        memset(p,0,sizeof p);
        memset(vis,0,sizeof vis);
        memset(l,0,sizeof l);
        for(int i=1;i<=n;i++) cin>>e[i].d>>e[i].v>>e[i].a;
        for(int i=1;i<=m;i++) cin>>p[i];
        bool pA = 1,pB = 1,pC = 1;
        for(int i=1;i<=n;i++){
            if(e[i].a != 0)pA = 0;
            if(e[i].a > 0)pC = 0;
            if(e[i].a < 0)pB = 0;
        }
        if(pA){//solve special situation A
            int ans=0;
            for(int i=1;i<=n;i++){
                int d = e[i].d;
                int v = e[i].v;
                if(d<=p[m] && v>v0)ans++;
            }
            cout<<ans<<' '<<ans<<endl;
        }else if(pB){//solve special situation B
            int ans = 0;
            for(int i=1;i<=n;i++){
                int d = e[i].d;
                int v = e[i].v;
                int a = e[i].a;
                if(d>p[m])continue;
                if(v*v+2*a*(p[m]-d)>v0*v0)ans++;
            }
            cout<<ans<<' '<<m-1<<endl;
        }else{
            ans1 = check();
            dfs(1);
            cout<<ans1<<' '<<ans2<<endl;
        }
    }
    return 0;
}










        /*
        for(int i=1;i<=n;i++){
            int d,v,a;
            cin>>d>>v>>a;
            if(a == 0){
                if(v<=v0)continue;
                if(v>v0){
                    printf("%d[%d,%d]\n",i,d,l0);
                    dis[d]++;dis[l0+1]--;
                }
            }else if(a>0){
                if(v<v0){
                    double d1 = (v0*v0-v*v)/(2.0*a)+d;
                    if(ceil(d1+0.5)>l0)continue;
                    printf("%d(%.2lf,%d]\n",i,d1,l0);
                    dis[(int)floor(d1)+1]++;dis[l0+1]--;
                }
                if(v==v0){
                    printf("%d(%d,%d]\n",i,d,l0);
                    dis[d+1]++;dis[l0+1]--;
                }
                if(v>v0){
                    printf("%d[%d,%d]\n",i,d,l0);
                    dis[d]++;dis[l0+1]--;
                }
            }else if(a<0){
                if(v<=v0)continue;
                if(v>v0){
                    double d1 = (v0*v0-v*v)/(2.0*a)+d;
                    if(ceil(d1+0.5)<l0 && d1>0){
                        printf("%d[%d,%.2lf)\n",i,d,d1);
                        dis[d]++;dis[(int)floor(d1+1)]--;
                    }else {
                        printf("%d[%d,%.2lf]\n",i,d,d1);
                        dis[d]++;dis[(int)floor(d1)+1]--;
                    }
                }
            }
        }
        */
